package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection c1=new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add("net");
        System.out.println("c1"+c1);
        Collection c2=new ArrayList();
        c2.add("ios");
        c2.add("androld");
        c2.add("java");
        System.out.println("c2"+c2);
        c1.addAll(c2);//将c2转到c1中
        System.out.println("c1"+c1);
        System.out.println("c2"+c2);
        Collection c3=new ArrayList();
        c3.add("java");
        c3.add("c++");
        c3.add("php");
        System.out.println("c3"+c3);
        boolean contains= c1.containsAll(c3);
        System.out.println("是否包含"+contains);
//        c1.retainAll(c3);
//        //取交集；c1中仅保留与c3所共有的元素，而c3不变
//        System.out.println("c1"+c1);//c1:{c++,andoid}
//        System.out.println("c3"+c3);//c3;{c++,and,php}
        c1.remove(c3);//删交集将c1于c3中共有的元素删除，c3不变
        System.out.println("c1"+c1);
        System.out.println("c3"+c3);

    }
}
